import { MotionProperties, ResolvedValueTarget, Target, Transition, useMotionTransitions, ValueTarget,useMotionControls } from "@vueuse/motion";


export function useTween<T extends MotionProperties>(target: T) {
    const { apply, stopTransitions } = useMotionControls(target)
    async function set(key: keyof T, transition: Transition) {
        return new Promise((r) => {
            apply({
                  [key]:[],
                transition:transition
            })?.then(()=>{
                r()
            })
            // push(key as string, [], target, {
            //     type: 'tween',
            //     from: target[key] || 0 as any, onComplete: () => {
            //         r(null)
            //     },
            //     ...transition
            // })
        })
    }
    return { set, stop:stopTransitions }
}